<template>
  <div>
    <h3>当前求和结果为: {{$store.state.sum}}</h3>
    <h3>放大十倍的结果为: {{$store.getters.bigSum}}</h3>
    {{sum}}
    <div>
      <select name="" id="" v-model.number="inputNumber">
        <option value="1">1</option>
        <option value="2">2</option>
        <option value="3">3</option>
      </select>
      <button @click="increment">+</button>
      <button @click="decrement">-</button>
      <button @click="incrementOdd">结果为奇数再加</button>
      <button @click="incrementAsync">异步+</button>
    </div>
  </div>
</template>

<script>
import { mapState,mapGetters } from "vuex";
export default {
  name:"Category",
  data() {
    return {
      inputNumber: 1
    }
  },
  methods: {
    increment() {
      // this.number += this.inputNumber
      // this.$store.dispatch('increment',this.inputNumber)
      this.$store.commit('INCREMENT',this.inputNumber)
    },
    decrement() {
      // this.number -= this.inputNumber
      // this.$store.dispatch('decrement',this.inputNumber)
      this.$store.commit('DECREMENT',this.inputNumber)
    },
    incrementOdd() {
      
      // this.number += this.inputNumber
      this.$store.dispatch('incrementOdd',this.inputNumber)
      
    },
    incrementAsync () {
      this.$store.dispatch('incrementAsync',this.inputNumber)
    }
  },
  computed:{
    a(){
      return 178
    },
    ...mapState({sum:'sum',name:'name'}),
    ...mapGetters({bigSum:'bigSum'}),

  }
}
</script>

<style>
  button {
    margin: 0 5px;
  }
</style>